﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<RankingSejmowy.UI.Core.ViewModels.Import.StatusViewModel>" %>
<%@ Import Namespace="RankingSejmowy.Common.Localization" %>
<%@ Import Namespace="RankingSejmowy.UI.Core.Extensions" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Status
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="import" class="hidden">
        <h2><%= AppStrings.InProgress%></h2>
        <span id="actualVoting"><img src="../../Content/Images/ajax-loader.gif" /></span>
        <p id="status"><%= Html.Encode(Model.Status) %></p>
    </div>
    <div id="noImport">
        <h2><%= AppStrings.ImportNotRunning %></h2>
    </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">

    <script type="text/javascript">

        var intervalId = 0;
        var importInProgress = "<%= Model.ImportInProgress %>".toLowerCase();

        function askForStatus() {
            $.post("<%= Url.ImportStatus() %>", null, function (data) {

                $("#status").text(data.Status);
                if (!data.ImportInProcess) {
                    clearInterval(intervalId);
                }

            });
        }

        $(function () {
            if (importInProgress == 'true') {
                $("#import").removeClass("hidden");
                $("#noImport").addClass("hidden");
                intervalId = setInterval(askForStatus, 5000);
            }
        });

    </script>
</asp:Content>
